﻿namespace MobileTrack.Core.Model
{
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Data.Services.Common;
    using System.Globalization;

    [Table("Marcas")]
    [EntityPropertyMapping("Nombre", SyndicationItemProperty.Title, SyndicationTextContentKind.Plaintext, true)]
    public class Marca : BaseEntity
    {
        public Marca()
        {
            this.Celulares = new List<Celular>();
        }

        public long ProveedorId { get; set; }

        public long Codigo { get; set; }

        [Required]
        [MaxLength(150)]
        public string Nombre { get; set; }

        public bool EsOperador { get; set; }

        [NotMapped]
        public string DisplayName
        {
            get { return string.Format(CultureInfo.InvariantCulture, "{0} ({1})", this.Nombre, this.Codigo); }
        }
        
        [ForeignKey("ProveedorId")]
        public virtual Proveedor Proveedor { get; set; }

        public virtual ICollection<Celular> Celulares { get; set; }
    }
}
